Repository navigation
Phase 3 (part 3): split lib/dma.c, lib/dai.c and intel_uaol.c, kernel parts to src/kernel - #11459
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The moved lookup remains directly callable from the LL user thread without a syscall boundary, violating the supervisor-only kernel contract.
1 open issue
What changed in this PR
This PR continues #11306’s kernel/user-space partition by splitting DMA, DAI and Intel UAOL code into application and kernel halves, with no intended functional change.
Changes:
- Moves DMA controller management, DAI device management and UAOL firmware queries into
src/kernel. - Updates build rules to include the new kernel files under the existing conditions.
- Updates partition documentation and classifies the remaining UAOL audio code as user code.
| File | Description |
|---|---|
src/lib/README.md |
Documents the DMA and DAI split. |
src/lib/dma.c |
Retains scatter-gather and buffer helpers. |
src/lib/dai.c |
Retains DAI group management. |
src/kernel/lib/dma-kernel.c |
Houses DMA lookup, reference counting and channel allocation. |
src/kernel/lib/dai-kernel.c |
Houses DAI device lookup and driver lifecycle operations. |
src/kernel/lib/CMakeLists.txt |
Builds both library kernel halves, including host builds. |
src/kernel/audio/intel_uaol-kernel.c |
Houses UAOL device lookup, capabilities and stream mapping. |
src/kernel/audio/CMakeLists.txt |
Builds the UAOL kernel half conditionally. |
src/include/sof/userspace/README.md |
Updates DMA and DAI implementation paths. |
src/audio/intel_uaol.c |
Retains feedback, rate adjustment and feedback DMA code. |
scripts/kernel_user_partition.txt |
Removes UAOL audio code from the kernel-source exceptions. |
Review effort: Balanced
| return -1; | ||
| } | ||
|
|
||
| const struct device *get_uaol_zdevice(int uaol_link_id) |
There was a problem hiding this comment.
Agreed, fixed in 928dd0b. The UAOL device table and get_uaol_zdevice() are back in src/audio/intel_uaol.c, so the code the LL user thread runs is exactly main's again. src/kernel/audio/intel_uaol-kernel.c now only has the two base firmware queries (tlv_value_set_uaol_caps() and uaol_stream_id_to_hda_link_stream_id()). They read the table through a declaration in sof/audio/intel_uaol.h, sized from the devicetree (DT_NUM_INST_STATUS_OKAY(intel_adsp_uaol)), so they still use ARRAY_SIZE() on it. The table stays in rodata, readable from user space. The only code change is one extra load in each kernel query, because the compiler can no longer fold the single-entry table into a constant.
dma.c mixes the DMA controller lookup with DMA buffer helpers that the host, DAI and copier components use, also in the user-space LL thread. Move the kernel part to src/kernel/lib/dma-kernel.c: - the kernel half of the sof_dma_get() and sof_dma_put() system calls, which pick a DMA controller, keep its reference count and allocate its channel array, with the accessors of the kernel-only DMA state; - dma_get() and dma_put() of the legacy (non-native) DMA drivers; - the DMA log module, UUID and trace context, which only that code uses. dma.c keeps the scatter-gather list helpers and the buffer copy functions. The kernel part is built wherever dma.c is, including the host library. The generated code is unchanged, apart from the line numbers that the DMA buffer copy functions pass to the assertion handler in builds with assertions (qemu_xtensa). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
dai.c mixes the DAI device lookup and the DAI getters with the DAI groups, which the DAI component uses, also in the user-space LL thread. Move the kernel part to src/kernel/lib/dai-kernel.c: - the Zephyr DAI device table and dai_get_device_list(), which the user-space access grants use; - the kernel half of the dai_get_device() system call; - dai_get() and dai_put() of the native and legacy DAI drivers, which probe and remove the DAI drivers and are called by the IPC3 handler and the platform code. dai.c keeps the DAI groups and the DAI log module and trace context, which both parts use. It no longer includes the Zephyr DAI driver and LL scheduler domain headers. The kernel part is built wherever dai.c is, including the host library. The generated code is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The UAOL feedback support made intel_uaol.c mixed: the DAI component calls the UAOL feedback, rate adjustment and feedback DMA functions from the user-space LL thread, while the base firmware queries the UAOL capabilities and stream mapping in kernel mode. Move the kernel part, tlv_value_set_uaol_caps() and uaol_stream_id_to_hda_link_stream_id(), with the IPC4 UAOL capabilities structures, to src/kernel/audio/intel_uaol-kernel.c. intel_uaol.c keeps the code that runs in the LL thread, including the UAOL device table and its lookup, get_uaol_zdevice(). The table is in rodata, readable from user space. It is no longer static: it is declared in sof/audio/intel_uaol.h, sized from the devicetree, so the kernel queries keep using ARRAY_SIZE() on it. intel_uaol.c is user code now, so drop it from the kernel sources listed under src/audio in the kernel include checker's manifest. The kernel part is built with the same condition as intel_uaol.c. The code is unchanged, but the two kernel queries now load the device from the table: with a single UAOL device, the compiler had reduced the static table to a constant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Update the src/lib and user-space READMEs for the split of dma.c and dai.c: their kernel parts, with the kernel halves of the sof_dma_get(), sof_dma_put() and dai_get_device() system calls, are now in src/kernel/lib. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
7d0ee9c to
1d75ad5
Compare
PR 11459: test resultsRun date: 2026-11-16 09:12 UTC Tested commit: 1d75ad585596336c4da7b4b17464238e502e87f9 |
|
CI failure unrelated. |

Phase 3 of #11306 (kernel / user-space partition), third part: split
lib/dma.c,lib/dai.candaudio/intel_uaol.c, and move their kernel parts intosrc/kernel. Based on current main (7f002a2), which includes #11422.As in the earlier parts, the kernel half of
src/X/foo.cissrc/kernel/X/foo-kernel.c, and each user half says where its kernel half is.Patches
lib/dma.c→kernel/lib/dma-kernel.c:sof_dma_get()/sof_dma_put()syscalls: DMA controller lookup, reference counting and channel allocation, with the accessors of the kernel-only DMA state;dma_get()/dma_put();dma.c: the scatter-gather helpers and the buffer copy functions that the host, DAI and copier components use, also in the user-space LL thread.lib/dai.c→kernel/lib/dai-kernel.c:dai_get_device_list(), which the user-space access grants use;dai_get_device()syscall;dai_get()/dai_put(), which probe and remove the DAI drivers and are called by the IPC3 handler and the platform code.dai.c: the DAI groups, which the DAI component uses.audio/intel_uaol.c→kernel/audio/intel_uaol-kernel.c:intel_uaol.c: the code that the DAI component runs in the LL thread: the feedback, rate adjustment and feedback DMA code, and the UAOL device table with its lookup,get_uaol_zdevice(). The table is in rodata, readable from user space. It is no longer static:sof/audio/intel_uaol.hdeclares it, sized from the devicetree, for the kernel queries.src/audioin the checker's manifest.src/liband user-space READMEs.The
dma/daikernel halves are built whereverdma.canddai.care, including the host library. The UAOL kernel half has the same condition asintel_uaol.c.Functional change
None. Every function of the three original files is present, character for character apart from
static/inline, in the user or kernel half. The per-function disassembly of every image was compared before and after each commit. It differs only in:dma.c: the line numbers the buffer copy functions pass to the assertion handler in qemu_xtensa, which has assertions enabled.dai.c: nothing.intel_uaol.c: the two kernel queries load the device from the table. With a single UAOL device, the compiler had reduced the static table to a constant. The code that runs in the LL thread is unchanged.Symbols, the
SYS_INIT()order, every build's.configand the generated rimage configurations are otherwise unchanged; compiler-generated switch tables are renumbered.Testing
Builds: tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx95 and qemu_xtensa, and the extra CI configurations:
CONFIG_SOF_USERSPACE_PROXY=n;os_linux_overlay.conf;llext_relocatable.conf.LNL, PTL, WCL and NVL build the UAOL support.
Comparisons: objects, LLEXT modules and firmware images (sections, symbols,
SYS_INIT()order), plus the per-function disassembly comparison above.Signing: rimage runs for every Intel platform, and the generated configs are unchanged.
Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile.
ZTest: the unit tests pass, run as in CI (18 of 18 configurations).
Host: the host library and the cmocka unit tests build and pass for all nine defconfigs and the library config.
sof-hda-generic-cavs25-2ch.tplg, comparing main and the previous push of this branch. That covers the DMA and DAI getters; TGL has no UAOL, and thedma.canddai.ccommits are unchanged since. Both boot, play 5 s, and play again after runtime suspend, with no DSP errors.All of the above, apart from the hardware test, was rerun on 7f002a2 (current main).
Changes since the last push
intel_uaol.c(Copilot review).get_uaol_zdevice()runs in the LL user thread, so it belongs in the user half, not in the supervisor-onlysrc/kernel. The table is now shared with the kernel queries throughsof/audio/intel_uaol.h. The LL-thread code is back to exactly main's code.🤖 Generated with Claude Code